//
//  YaoqingController.m
//  ToListenPhone
//
//  Created by zhibao on 2023/7/18.
//

#import "FLSFenXiangDetailController.h"

@interface FLSFenXiangDetailController (){
    UIScrollView *scrollview;
}
@property (nonatomic,strong) UIActivityViewController *activityVC;
@property(nonatomic,strong)NSMutableArray *dataArray;
@property(nonatomic,assign)int allPeople;
@property(nonatomic,assign)int vipDay;
@property(nonatomic,assign)int yaoqingDay;
@property(nonatomic,assign)int beiyaoqingjifen;

@end

@implementation FLSFenXiangDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.gk_backImage = nil;
    self.view.backgroundColor = UIColor.whiteColor;
    self.gk_navigationBar.hidden = YES;
    self.gk_statusBarStyle = UIStatusBarStyleLightContent;
    [self hideNavLine];
    
    UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
    [appearance configureWithOpaqueBackground];
    appearance.backgroundColor = UIColor.clearColor;
    //去掉导航栏下的阴影线
    appearance.shadowColor = UIColor.clearColor;
    self.gk_navigationBar.standardAppearance = appearance;
    self.gk_navigationBar.scrollEdgeAppearance = self.gk_navigationBar.standardAppearance;
    
    UIButton *yaoqingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    yaoqingBtn.frame = CGRectMake(15, MY_Screen_H - SafeBottomMargin - 45, MY_Screen_W - 30, 46);
    yaoqingBtn.layer.cornerRadius = 23;
    [yaoqingBtn setTitle:@"邀请1位新用户，即可获取VIP" forState:UIControlStateNormal];
    [yaoqingBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    yaoqingBtn.titleLabel.font = MY_SCALE_SemiboldFONT(14);
    [yaoqingBtn addTarget:self action:@selector(yaoqingCode) forControlEvents:UIControlEventTouchUpInside];
    [Helper setDiferentColors:@[(id)MyColor(@"#FFCB10").CGColor,(id)MyColor(@"#FF7305").CGColor] WithView:yaoqingBtn withFlag:ColorDirectionLeft];
    [self.view addSubview:yaoqingBtn];
    
    scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, MY_Screen_W, yaoqingBtn.top - 20)];
    scrollview.backgroundColor = MyColor(@"#FFCE00");
    [self.view addSubview:scrollview];
    
    scrollview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@"arrow_back_white"] forState:UIControlStateNormal];
    [self.view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(0);
        make.width.height.mas_offset(40);
        make.top.mas_equalTo(NAVIH - 25);
    }];
    [btn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        [self back];
    }]];
    
    _dataArray = [NSMutableArray new];
    __weak __typeof(self)weakSelf = self;
    [[HttpHelper sharedInstance] sendGet:@"api/invitation/history" parameters:@{} success:^(NSURLSessionTask * _Nonnull operation, ResponseModel * _Nonnull responseObject) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        strongSelf.allPeople = [responseObject.data[@"data"][@"people_count"] intValue];
        strongSelf.vipDay = [responseObject.data[@"data"][@"vip_days"] intValue];
        strongSelf.dataArray = responseObject.data[@"data"][@"list"];
        NSDictionary *tempDic = responseObject.data[@"data"][@"welfare"];
        strongSelf.beiyaoqingjifen = [tempDic[@"invitee"][@"value"] intValue];
        strongSelf.yaoqingDay = [tempDic[@"inviter"][@"value"] intValue];
        [strongSelf initView];
    } failure:^(NSURLSessionTask * _Nonnull operation, NSError * _Nonnull error) {
        
    }];
}

-(void)initView{
    
    UIImageView *imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"fulishe_yaoqing_bg"]];
    [scrollview addSubview:imgView];
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(scrollview);
    }];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.backgroundColor = MyColor(@"#ffffff");
    [btn setTitle:@"活动细则" forState:UIControlStateNormal];
    [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    [btn setTitleColor:MyColor(@"#E47B17") forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnclick) forControlEvents:UIControlEventTouchUpInside];
    btn.titleLabel.font = MY_SCALE_RegularFONT(12);
    btn.layer.cornerRadius = 13;
    [scrollview addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view).offset(13);
        make.width.mas_equalTo(76 + 13);
        make.height.mas_equalTo(26);
        make.top.mas_equalTo(83 + NAVIH - 64);
    }];
    
    UIView *yaoqingView = [[UIView alloc]init];
    yaoqingView.backgroundColor = MyColor(@"#FFF0B5");
    yaoqingView.layer.cornerRadius = 10;
    [scrollview addSubview:yaoqingView];
    [yaoqingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.equalTo(self.view).offset(-10);
        make.top.equalTo(btn.mas_bottom).offset(302);
    }];
    
    UIImageView *yaoqingImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"fulishe_yaoqing_title"]];
    [scrollview addSubview:yaoqingImgView];
    [yaoqingImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(yaoqingView);
        make.centerY.equalTo(yaoqingView.mas_top);
    }];
    
    UILabel *yaoqingLabel = [UILabel new];
    yaoqingLabel.text = @"邀请流程";
    yaoqingLabel.textColor = MyColor(@"#E84931");
    yaoqingLabel.font = MY_SCALE_SemiboldFONT(18);
    [yaoqingImgView addSubview:yaoqingLabel];
    
    [yaoqingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(39);
        make.centerY.equalTo(yaoqingImgView);
    }];
    
    if(yaoqingView){
        NSArray *contents = @[
            @{
                @"title":@"① 点击邀请按钮邀请好友",
                @"img":@"fulishe_yaoqing_1"
            },
            @{
                @"title":@"② 被邀请人领取邀请码",
                @"img":@"fulishe_yaoqing_2"
            },
            @{
                @"title":@"③ 被邀请人在APP中【我的-福利社-兑换邀请码】中兑换邀请码",
                @"img":@"fulishe_yaoqing_3"
            },
            @{
                @"title":[NSString stringWithFormat:@"④ 邀请人获得%d天VIP会员，被邀请人获得%d积分",self.yaoqingDay,self.beiyaoqingjifen],
                @"img":@"fulishe_yaoqing_4"
            },
        ];
        
        UIView *tempView;
        for (int i = 0; i < contents.count; i ++) {
            UILabel *detailLabel = [UILabel new];
            detailLabel.text = contents[i][@"title"];
            detailLabel.textColor = MyColor(@"333333");
            detailLabel.font = MY_SCALE_RegularFONT(12);
            detailLabel.numberOfLines = 0;
            detailLabel.lineBreakMode = NSLineBreakByWordWrapping;
            [yaoqingView addSubview:detailLabel];
            
            [detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(55);
                make.right.mas_equalTo(-20);
                if(tempView){
                    make.top.equalTo(tempView.mas_bottom).offset(22);
                }else{
                    make.top.mas_equalTo(50);
                }
                if(i == contents.count - 1){
                    make.bottom.equalTo(yaoqingView).offset(-34);
                }
            }];
            
            UIImageView *imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:contents[i][@"img"]]];
            [yaoqingView addSubview:imgView];
            [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(15);
                make.centerY.equalTo(detailLabel);
            }];
            
            tempView = detailLabel;
        }
    }
    
    
    UIView *jiangliView = [[UIView alloc]init];
    jiangliView.backgroundColor = MyColor(@"#FFF0B5");
    jiangliView.layer.cornerRadius = 10;
    [scrollview addSubview:jiangliView];
    [jiangliView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.equalTo(self.view).offset(-10);
        make.top.equalTo(yaoqingView.mas_bottom).offset(37);
        make.bottom.equalTo(scrollview).offset(-30);
    }];
    
    UIImageView *jiangliImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"fulishe_yaoqing_title"]];
    [scrollview addSubview:jiangliImgView];
    [jiangliImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(jiangliView);
        make.centerY.equalTo(jiangliView.mas_top);
    }];
    
    UILabel *jiangliLabel = [UILabel new];
    jiangliLabel.text = @"奖励明细";
    jiangliLabel.textColor = MyColor(@"#E84931");
    jiangliLabel.font = MY_SCALE_SemiboldFONT(18);
    [jiangliImgView addSubview:jiangliLabel];
    
    [jiangliLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(39);
        make.centerY.equalTo(jiangliImgView).offset(-3);
    }];
    
    if(jiangliView){
        UIView *numView = [[UIView alloc]init];
        numView.backgroundColor = UIColor.whiteColor;
        numView.layer.cornerRadius = 10;
        [jiangliView addSubview:numView];
        [numView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(17.5);
            make.right.mas_equalTo(-17.5);
            make.top.mas_equalTo(32);
            make.height.mas_equalTo(80);
        }];
        CGFloat numWidth = (MY_Screen_W - 10 - 17.5 - 10 - 17.5) / 2 - 20;
        UILabel *yaoNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 13, numWidth, 35)];
        yaoNumLabel.text = [NSString stringWithFormat:@"%d",self.allPeople];
        yaoNumLabel.font = MY_SCALE_SemiboldFONT(25);
        yaoNumLabel.textAlignment = NSTextAlignmentCenter;
        yaoNumLabel.textColor = MyColor(@"#FF8007");
        [numView addSubview:yaoNumLabel];
        
        UILabel *cyaoNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, yaoNumLabel.bottom + 5, numWidth, 16)];
        cyaoNumLabel.text = @"邀请总人数";
        cyaoNumLabel.font = MY_SCALE_RegularFONT(12);
        cyaoNumLabel.textAlignment = NSTextAlignmentCenter;
        cyaoNumLabel.textColor = MyColor(@"#999999");
        [numView addSubview:cyaoNumLabel];
        
        UILabel *vipNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(yaoNumLabel.right + 20, 13, numWidth, 35)];
        vipNumLabel.text = [NSString stringWithFormat:@"%d",self.vipDay];
        vipNumLabel.font = MY_SCALE_SemiboldFONT(25);
        vipNumLabel.textAlignment = NSTextAlignmentCenter;
        vipNumLabel.textColor = MyColor(@"#FF8007");
        [numView addSubview:vipNumLabel];
        
        UILabel *cvipNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(yaoNumLabel.right + 20, vipNumLabel.bottom + 5, numWidth, 16)];
        cvipNumLabel.text = @"VIP天数";
        cvipNumLabel.font = MY_SCALE_RegularFONT(12);
        cvipNumLabel.textAlignment = NSTextAlignmentCenter;
        cvipNumLabel.textColor = MyColor(@"#999999");
        [numView addSubview:cvipNumLabel];

        UILabel *tipLabel = [UILabel new];
        tipLabel.text = @"*怎样赢得更多的收益？可以邀请更多的用户哦！";
        tipLabel.font = MY_SCALE_RegularFONT(12);
        tipLabel.textColor = MyColor(@"#C79870");
        [jiangliView addSubview:tipLabel];
        [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(numView);
            make.top.equalTo(numView.mas_bottom).offset(7);
        }];
        
        UIView *bottomView = [UIView new];
        bottomView.backgroundColor = UIColor.whiteColor;
        bottomView.layer.cornerRadius = 10;
        [jiangliView addSubview:bottomView];
        bottomView.clipsToBounds = YES;
        [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(numView);
            make.top.equalTo(tipLabel.mas_bottom).offset(15);
            make.bottom.equalTo(jiangliView).offset(-30);
        }];
        
        UILabel *yaoTitleLabel = [UILabel new];
        yaoTitleLabel.text = @"邀请明细";
        yaoTitleLabel.font = MY_SCALE_SemiboldFONT(15);
        yaoTitleLabel.textAlignment = NSTextAlignmentCenter;
        yaoTitleLabel.textColor = MyColor(@"#ffffff");
        yaoTitleLabel.backgroundColor = MyColor(@"#FFBB22");
        [Helper setDiferentColors:@[(id)MyColor(@"#FFCB10").CGColor,(id)MyColor(@"#FF7305").CGColor] WithView:yaoTitleLabel withFlag:ColorDirectionLeft];
        [bottomView addSubview:yaoTitleLabel];
        [yaoTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(bottomView);
            make.height.mas_equalTo(45);
        }];
        
        UIView *tempView = yaoTitleLabel;
        for (int i = 0; i < self.dataArray.count; i ++) {
            
            UIView *bgView = [UIView new];
            bgView.backgroundColor = MyColor(@"#FFF9F3");
            bgView.layer.cornerRadius = 15;
            [bottomView addSubview:bgView];
            [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(15);
                make.right.mas_equalTo(-15);
                make.height.mas_equalTo(30);
                make.top.equalTo(tempView.mas_bottom).offset(25);
                if(i == self.dataArray.count - 1){
                    make.bottom.equalTo(bottomView).offset(-34);
                }
            }];
            UILabel *phoneLabel = [UILabel new];
            phoneLabel.text = self.dataArray[i][@"uuid"];
            phoneLabel.textColor = MyColor(@"333333");
            phoneLabel.font = MY_SCALE_RegularFONT(14);
            [bgView addSubview:phoneLabel];
            
            [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(15);
                make.top.bottom.equalTo(bgView);
            }];
            
            UILabel *timeLabel = [UILabel new];
            timeLabel.text = self.dataArray[i][@"date"];
            timeLabel.textColor = MyColor(@"999999");
            timeLabel.font = MY_SCALE_RegularFONT(12);
            [bgView addSubview:timeLabel];
            
            [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.mas_equalTo(-15);
                make.top.bottom.equalTo(bgView);
            }];
            
            tempView = bgView;
        }
    }
}

-(void)yaoqingCode{

    UIView * bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, MY_Screen_W, MY_Screen_H)];
    bgView.backgroundColor = [MYColor colorWithHexString:@"111111" alpha:0.3];
    
    CGFloat height = 400 + SafeBottomMargin;
    UIView *contentView = [[UIView alloc]initWithFrame:CGRectMake(0, MY_Screen_H, MY_Screen_W, height + 15)];
    contentView.backgroundColor = UIColor.whiteColor;
    contentView.layer.cornerRadius = 15;
    [bgView addSubview:contentView];
    
    UIButton *hideBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    hideBtn.backgroundColor = [UIColor clearColor];
    
    [hideBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        [bgView removeFromSuperview];
    }]];
    hideBtn.frame = CGRectMake(0, 0, MY_Screen_W, MY_Screen_H  - height);
    [bgView addSubview:hideBtn];
    [[UIApplication sharedApplication].delegate.window.rootViewController.view addSubview:bgView];
    
    UIImageView *topImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, MY_Screen_W, 178)];
    topImgView.image = [UIImage imageNamed:@"fulishe_yaoqing_code"];
    [contentView addSubview:topImgView];
    
    UIButton *canCelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    canCelBtn.frame = CGRectMake(MY_Screen_W - 40 - 17, 12, 40, 40);
    [canCelBtn setImage:[UIImage imageNamed:@"com_close"] forState:UIControlStateNormal];
    [contentView addSubview:canCelBtn];
    [canCelBtn addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithActionBlock:^(id  _Nonnull sender) {
        [UIView animateWithDuration:0.2 animations:^{
            contentView.top = MY_Screen_H;
        } completion:^(BOOL finished) {
            [bgView removeFromSuperview];
        }];
    }]];
    
    UIView *view = [[UIView alloc] init];
    view.frame = CGRectMake(17.5,101,MY_Screen_W - 35,265);

    view.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor;
    view.layer.cornerRadius = 10;
    view.layer.shadowColor = [UIColor colorWithRed:116/255.0 green:116/255.0 blue:116/255.0 alpha:0.2000].CGColor;
    view.layer.shadowOffset = CGSizeMake(0,0);
    view.layer.shadowOpacity = 1;
    view.layer.shadowRadius = 5;
    [contentView addSubview:view];
    
    UILabel *cCodeLabel = [[UILabel alloc]init];
    cCodeLabel.text = @"我的邀请码";
    cCodeLabel.font = MY_SCALE_RegularFONT(14);
    cCodeLabel.textColor = MyColor(@"#999999");
    cCodeLabel.textAlignment = NSTextAlignmentCenter;
    [view addSubview:cCodeLabel];
    [cCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(view);
        make.top.mas_equalTo(28);
    }];
    
    UILabel *codeLabel = [[UILabel alloc]init];
    codeLabel.text = [UserInfoManager sharedManager].invitation_code;
    codeLabel.font = MY_SCALE_SemiboldFONT(25);
    codeLabel.textColor = MyColor(@"#333333");
    codeLabel.textAlignment = NSTextAlignmentCenter;
    [view addSubview:codeLabel];
    [codeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(view);
        make.top.equalTo(cCodeLabel.mas_bottom).offset(5);
    }];
    
    UIButton *copyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    copyBtn.frame = CGRectMake(20, 105, view.width - 40, 50);
    copyBtn.layer.cornerRadius = 25;
    [copyBtn setTitle:@"复制邀请码" forState:UIControlStateNormal];
    [copyBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    copyBtn.titleLabel.font = MY_SCALE_SemiboldFONT(17);
    [Helper setDiferentColors:@[(id)MyColor(@"#FE513E").CGColor,(id)MyColor(@"#FFA90F").CGColor] WithView:copyBtn withFlag:ColorDirectionLeft];
    [view addSubview:copyBtn];
    [copyBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        DLog(@"复制");
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.string = [UserInfoManager sharedManager].invitation_code;
        [QMUITips showSucceed:@"复制成功"];
    }]];
    
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    shareBtn.frame = CGRectMake(20, 175, view.width - 40, 50);
    shareBtn.layer.cornerRadius = 25;
    [shareBtn setTitle:@"分享App" forState:UIControlStateNormal];
    [shareBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    shareBtn.titleLabel.font = MY_SCALE_SemiboldFONT(17);
    [Helper setDiferentColors:@[(id)MyColor(@"#3E6FFE").CGColor,(id)MyColor(@"#30D1FF").CGColor] WithView:shareBtn withFlag:ColorDirectionLeft];
    [view addSubview:shareBtn];
    [shareBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        DLog(@"分享");
        NSString *textToShare = LocalizedString(@"我正在使用谛听通话录音APP，接打电话智能录音，专业维权工具，音质清晰，你也来一起使用吧");//需要分享的文本内容
        UIImage *imageToShare = [UIImage imageNamed:@"common_share"];//需要分享的图片
        NSURL *urlToShare = [NSURL URLWithString:@"https://apps.apple.com/cn/app/%E8%B0%9B%E5%90%AC%E9%80%9A%E8%AF%9D%E5%BD%95%E9%9F%B3-%E6%89%8B%E6%9C%BA%E7%94%B5%E8%AF%9D%E5%BD%95%E9%9F%B3%E5%8F%96%E8%AF%81%E8%BD%AF%E4%BB%B6/id6443703983"];//需要分享的URL
        NSArray *activityItems = @[textToShare, imageToShare, urlToShare];
        self.activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
        // 禁用分享渠道
        //            activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
        //            UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll];
        // 分享之后的回调
        self.activityVC.completionWithItemsHandler = ^(UIActivityType  _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
            if (completed) {
                NSLog(@"成功分享,分享平台%@",activityType);
            }else{
                NSLog(@"取消分享");
            };
        };
        
        [self presentViewController:self.activityVC animated:true completion:nil];
    }]];
    
    [UIView animateWithDuration:0.2 animations:^{
        contentView.top = MY_Screen_H - height;
    } completion:^(BOOL finished) {
        
    }];
}

-(void)btnclick{
    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, MY_Screen_W, MY_Screen_H)];
    bgView.backgroundColor = [MYColor colorWithHexString:@"#010811" alpha:0.6];
    [[UIApplication sharedApplication].delegate.window addSubview:bgView];
    UIView *contentView = [[UIView alloc]init];
    contentView.backgroundColor = UIColor.whiteColor;
    contentView.layer.cornerRadius = 10;
    [bgView addSubview:contentView];
    [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(50);
        make.right.mas_equalTo(-50);
        make.center.equalTo(bgView);
    }];
    
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel.text = @"活动细则";
    titleLabel.font = MY_SCALE_RegularFONT(15);
    titleLabel.textColor = MYBlock;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [contentView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.top.equalTo(contentView);
        make.height.mas_equalTo(46);
    }];
    
    UILabel *contentLabel = [[UILabel alloc]init];
    contentLabel.text = @"1、用户可分享邀请码给好友，好友复制邀请码后，进入APP中【我的-福利社-兑换邀请码】中点击兑换邀请码完成兑换后即完成分享任务；\n 2、该分享活动仅限新用户接受邀请，同一个用户只能兑换一次邀请码； \n3、好友兑换成功后，用户和好友即可获得奖励； \n4、每位用户可以邀请多位新用户参加此活动，获得的奖励可以叠加； \n5、任何人以任何不正当手段参与活动并获得权益的、或者用户账号存在风险行为的，我们有权取消该用户的参与资格并撤销其权益，且保留追究该用户责任的权利。";
    contentLabel.numberOfLines = 0;
    contentLabel.lineBreakMode = NSLineBreakByWordWrapping;
    contentLabel.font = MY_SCALE_RegularFONT(12);
    contentLabel.textColor = MyColor(@"666666");;
    [contentView addSubview:contentLabel];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom).offset(3);
        make.left.right.equalTo(titleLabel);
    }];
    
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = MyColor(@"#EEEEEE");
    [contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(contentView);
        make.height.mas_equalTo(0.5);
        make.top.equalTo(contentLabel.mas_bottom).offset(20);
    }];
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [contentView addSubview:btn];
    [btn setTitle:@"确定" forState:UIControlStateNormal];
    [btn setTitleColor:MYBlock forState:UIControlStateNormal];
    btn.titleLabel.font = MY_SCALE_SemiboldFONT(14);
    [btn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        [bgView removeFromSuperview];
    }]];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(contentView);
        make.top.equalTo(line.mas_bottom);
        make.height.mas_equalTo(40);
        make.bottom.equalTo(contentView);
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
